package com.zyh.config;

import com.zyh.filter.AccessControlAllowFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration//指明该类为一个配置类
public class MywebConfig implements WebMvcConfigurer {
    @Bean
    public FilterRegistrationBean filterRegist() {
//        1,创建filter注册表对象
        FilterRegistrationBean frBean = new FilterRegistrationBean();
//        2,将filter放入注册表中
        frBean.setFilter(new AccessControlAllowFilter());
//        3,配置拦截路径
        frBean.addUrlPatterns("/*");
        return frBean;
    }
}
